﻿@{
    ViewData["Title"] = "参数设置";
    Layout = "~/Areas/Manager/Views/Shared/_Layout.cshtml";
}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">参数设置</div>
                <div class="layui-card-body">
                    <div class="layui-row">
                        <div class="layui-form-item">
                            <div class="layui-col-md3" style="padding-left:0">
                                <div class="input-group">
                                    <input type="text" id="keyWords" name="keyWords" placeholder="请输入查找的内容" autocomplete="off" class="layui-input">
                                    <span class="input-group-btn">
                                        <button class="layui-btn" id="search">
                                            <i class="layui-icon layui-icon-search"></i>
                                        </button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    <div class="layui-row">
                        <div class="layui-btn-container">
                            <div class="layui-btn-group">
                                <button class="layui-btn layui-btn-sm" id="add"><i class="layui-icon">&#xe654;</i>增加</button>
                                <button class="layui-btn layui-btn-sm layui-btn-danger" id="deleteAll"><i class="layui-icon">&#xe640;</i>删除</button>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <table class="layui-table" lay-data="{page:true, id:'list'}" lay-filter="list">
                            <thead>
                                <tr>
                                    <th lay-data="{checkbox:true, fixed: true}"></th>
                                    <th lay-data="{field:'csId',width:90}">ID</th>
                                    <th lay-data="{field:'keyName'}">键</th>
                                    <th lay-data="{field:'keyValue'}">值</th>
                                    <th lay-data="{field:'keyType',templet: '#buttonTpl',width:100}">类型</th>
                                    <th lay-data="{field:'description'}">说明</th>
                                    <th lay-data="{field:'createDate',width:200}">创建时间</th>
                                    <th lay-data="{toolbar:'#tableoption',fixed: 'right',width:90}">操作</th>
                                </tr>
                            </thead>
                        </table>
                        <script type="text/html" id="buttonTpl">
                            {{#  if(d.keyType==1){ }}
                            <span class="layui-badge layui-bg-green">系统</span>
                            {{#  } else { }}
                            <span class="layui-badge layui-bg-orange">非系统</span>
                            {{#  } }}
                        </script>
                        <script type="text/html" id="tableoption">
                            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section scriptsfeet
{
<script type="text/javascript">
        layui.config({
            base: '/layuiadmin/' //自定义模块路径
        }).use(['sykjwh', 'table'], function () {
            var $ = layui.$, sykjwh = layui.sykjwh, table = layui.table;

            //绑定数据
            sykjwh.dataBind('@Url.Action("list", "config", new { area = Constant.AREAMANAGER })');

            //添加
            $("#add").click(function () {
                sykjwh.open('添加参数', '@Url.Action("add", "config", new { area = Constant.AREAMANAGER })', 700, 400);
            });

            //批量删除
            $("#deleteAll").click(function () {
                sykjwh.batOperate('@Url.Action("deleteall", "config", new { area = Constant.AREAMANAGER })', 'csId');
            });

            //监听表格行
            table.on('tool(list)', function (obj) {
                var data = obj.data;//获得当前行数据
                if (obj.event === 'edit') {
                    sykjwh.open('编辑参数', '@Url.Action("edit", "config", new { area = Constant.AREAMANAGER })/' + data.csId, 700, 400);
                }
            });

            //搜索
            $("#search").click(function () {
                //绑定数据
                sykjwh.dataBind('@Url.Action("list", "config", new { area = Constant.AREAMANAGER })', {
                    keyWords: $.trim($("#keyWords").val())
                });
            });
        });
</script>
}